package com.ywl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ywl.mapper.GradeMapper;
import com.ywl.mapper.StudentMapper;
import com.ywl.pojo.Grade;
import com.ywl.pojo.Student;
import com.ywl.service.GradeService;
import com.ywl.service.StudentService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.thymeleaf.util.StringUtils;

import java.util.List;

/**
 * @author DL5O
 * @version 1.0
 */

@Service("gradeServiceImpl")
@Transactional
public class GradeServiceImpl extends ServiceImpl<GradeMapper, Grade> implements GradeService {


    @Override
    public IPage<Grade> getGradeByOpr(Page<Grade> pageParam, String gradeName) {
        QueryWrapper<Grade> queryWrapper = new QueryWrapper<>();
        if (!StringUtils.isEmpty(gradeName)) {
            queryWrapper.like("name",gradeName);//查找包含关键字的名称
        }
        Page<Grade> page = baseMapper.selectPage(pageParam, queryWrapper);//第几页，也大小
        return page;
    }

    @Override
    public List<Grade> getGrades() {
       return baseMapper.selectList(null);
    }
}
